import rclpy
from rclpy.node import Node
class Params_node(Node):
    def __init__(self,name):
        super().__init__(name)
        self.get_logger().info('This is a prams node: {}'.format(name))
        self.declare_parameter('params_level',0)
        log_level = self.get_parameter('params_level').value
        self.get_logger().set_level(log_level)
        self.timer = self.create_timer(3,self.time_callback)
        
    def time_callback(self):
        log_level = self.get_parameter("params_level").value
        # 设置参数
        self.get_logger().set_level(log_level)
        print(
            f"========================{log_level}=============================")
        self.get_logger().debug("debug log!")
        self.get_logger().info("INFO log!")
        self.get_logger().warn("WARN log!")
        self.get_logger().error("ERROR log!")
        self.get_logger().fatal("FATAL log!")

def main(args=None):
    rclpy.init(args=args)
    node = Params_node('params_node')
    rclpy.spin(node)
    rclpy.shutdown()
